/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author owtee
 */
@Entity
@Table(name = "department")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Department.findAll", query = "SELECT d FROM Department d"),
    @NamedQuery(name = "Department.findByDepId", query = "SELECT d FROM Department d WHERE d.depId = :depId"),
    @NamedQuery(name = "Department.findByDepName", query = "SELECT d FROM Department d WHERE d.depName = :depName"),
    @NamedQuery(name = "Department.findByActiveFlag", query = "SELECT d FROM Department d WHERE d.activeFlag = :activeFlag"),
    @NamedQuery(name = "Department.findByCreateUser", query = "SELECT d FROM Department d WHERE d.createUser = :createUser"),
    @NamedQuery(name = "Department.findByCreateDate", query = "SELECT d FROM Department d WHERE d.createDate = :createDate"),
    @NamedQuery(name = "Department.findByModifyUser", query = "SELECT d FROM Department d WHERE d.modifyUser = :modifyUser"),
    @NamedQuery(name = "Department.findByModifyDate", query = "SELECT d FROM Department d WHERE d.modifyDate = :modifyDate")})
public class Department implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "Dep_Id")
    private Integer depId;
    @Size(max = 50)
    @Column(name = "Dep_Name")
    private String depName;
    @Column(name = "Active_Flag")
    private Boolean activeFlag;
    @Size(max = 10)
    @Column(name = "Create_User")
    private String createUser;
    @Column(name = "Create_Date")
    @Temporal(TemporalType.TIMESTAMP)
    private Date createDate;
    @Size(max = 10)
    @Column(name = "Modify_User")
    private String modifyUser;
    @Column(name = "Modify_Date")
    @Temporal(TemporalType.TIMESTAMP)
    private Date modifyDate;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "depId")
    private Collection<Users> usersCollection;
    @JoinColumn(name = "Com_Id", referencedColumnName = "Com_Id")
    @ManyToOne(optional = false)
    private Company comId;

    public Department() {
    }

    public Department(Integer depId) {
        this.depId = depId;
    }

    public Integer getDepId() {
        return depId;
    }

    public void setDepId(Integer depId) {
        this.depId = depId;
    }

    public String getDepName() {
        return depName;
    }

    public void setDepName(String depName) {
        this.depName = depName;
    }

    public Boolean getActiveFlag() {
        return activeFlag;
    }

    public void setActiveFlag(Boolean activeFlag) {
        this.activeFlag = activeFlag;
    }

    public String getCreateUser() {
        return createUser;
    }

    public void setCreateUser(String createUser) {
        this.createUser = createUser;
    }

    public Date getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    public String getModifyUser() {
        return modifyUser;
    }

    public void setModifyUser(String modifyUser) {
        this.modifyUser = modifyUser;
    }

    public Date getModifyDate() {
        return modifyDate;
    }

    public void setModifyDate(Date modifyDate) {
        this.modifyDate = modifyDate;
    }

    @XmlTransient
    public Collection<Users> getUsersCollection() {
        return usersCollection;
    }

    public void setUsersCollection(Collection<Users> usersCollection) {
        this.usersCollection = usersCollection;
    }

    public Company getComId() {
        return comId;
    }

    public void setComId(Company comId) {
        this.comId = comId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (depId != null ? depId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Department)) {
            return false;
        }
        Department other = (Department) object;
        if ((this.depId == null && other.depId != null) || (this.depId != null && !this.depId.equals(other.depId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.Department[ depId=" + depId + " ]";
    }
    
}
